package com.zsp.exception;

public class InvalidExtensionException extends RuntimeException {

    private static final long serialVersionUID = 1L;

    private final String[] allowedExtensions;
    private final String extension;
    private final String fileName;

    public InvalidExtensionException(String[] allowedExtensions, String extension, String fileName) {
        super("文件扩展名不合法，允许的扩展名为：" + String.join(",", allowedExtensions));
        this.allowedExtensions = allowedExtensions;
        this.extension = extension;
        this.fileName = fileName;
    }

    public String[] getAllowedExtensions() {
        return allowedExtensions;
    }

    public String getExtension() {
        return extension;
    }

    public String getFileName() {
        return fileName;
    }

    public static class InvalidImageExtensionException extends InvalidExtensionException {

        private static final long serialVersionUID = 1L;

        public InvalidImageExtensionException(String[] allowedExtensions, String extension, String fileName) {
            super(allowedExtensions, extension, fileName);
        }
    }

    public static class InvalidFlashExtensionException extends InvalidExtensionException {

        private static final long serialVersionUID = 1L;

        public InvalidFlashExtensionException(String[] allowedExtensions, String extension, String fileName) {
            super(allowedExtensions, extension, fileName);
        }
    }

    public static class InvalidMediaExtensionException extends InvalidExtensionException {

        private static final long serialVersionUID = 1L;

        public InvalidMediaExtensionException(String[] allowedExtensions, String extension, String fileName) {
            super(allowedExtensions, extension, fileName);
        }
    }

    public static class InvalidVideoExtensionException extends InvalidExtensionException {

        private static final long serialVersionUID = 1L;

        public InvalidVideoExtensionException(String[] allowedExtensions, String extension, String fileName) {
            super(allowedExtensions, extension, fileName);
        }
    }
}
